# -*- coding:utf-8 -*-

from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet


from Apps.UiTest.filters.uiTestCaseLogFilter import UiTestCaseLogFilter
from Apps.UiTest.models import UiTestCaseLog
from Apps.UiTest.ser.uiTestCaseLogSer import UiTestCaseLogSer

import logging

from Apps.common.response import SuccessResponse

logger = logging.getLogger("django")


class UiTestCaseLogView(ModelViewSet):
    queryset = UiTestCaseLog.objects.all()
    serializer_class = UiTestCaseLogSer
    filter_class = UiTestCaseLogFilter

    def list(self, request, *args, **kwargs):
        queryset = self.filter_queryset(self.get_queryset())

        page = self.paginate_queryset(queryset)
        if page is not None:
            serializer = self.get_serializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = self.get_serializer(queryset, many=True)
        return SuccessResponse(serializer.data)

